package bbs.controller;

import bbs.exception.ControllerException;
import bbs.model.Topic;
import bbs.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 *  主题 部分
 *  @author ljg;
 * @create 2022-06-08 10:19
 */
@Controller
@RequestMapping("/topic")
public class TopicController {

    @Autowired
    TopicService topicService ;


    @RequestMapping("/getTopicByBoardId")
    public String getTopicByBoardId(@RequestParam("boardId") Integer boardId,
                                    Map<String,Object> map){

        try {
            List<Topic> topics = topicService.getTopicByBoardId(boardId);
            System.out.println(topics.size());
            map.put("topicList", topics);
            return "board_detail" ;
        } catch (Exception e) {
            throw new ControllerException(e) ;
        }

    }
}
